import java.lang.reflect.Array;
import java.util.Arrays;

public class lk6285 {
    public static void main(String[] args) {
        
    }
    public long maxKelements(int[] nums, int k) {
        int n=nums.length;
        long end=0l;
        Arrays.sort(nums);
        if(n>=100)
        while(k-->0){
            if(nums[n-1]>nums[n-2]&&nums[n-1]>nums[n-3]&&nums[n-1]>nums[n-4]&&nums[n-1]>nums[n-5]){
                end+=(long)nums[n-1];
                nums[n-1]=(int) Math.ceil((double)nums[n-1]/3);
            }else if(nums[n-2]>nums[n-3]&&nums[n-2]>nums[n-4]&&nums[n-2]>nums[n-5]){
                end+=(long)nums[n-2];
                nums[n-2]=(int) Math.ceil((double)nums[n-2]/3);
            }else if(nums[n-3]>nums[n-4]&&nums[n-3]>nums[n-5]){
                end+=(long)nums[n-3];
                nums[n-3]=(int) Math.ceil((double)nums[n-3]/3);
            }else if(nums[n-4]>nums[n-5]){
                end+=(long)nums[n-4];
                nums[n-4]=(int) Math.ceil((double)nums[n-4]/3);
            }else if(nums[n-5]>nums[n-6]){
                end+=(long)nums[n-5];
                nums[n-5]=(int) Math.ceil((double)nums[n-5]/3);
                Arrays.sort(nums);
            }
            
        return end;
    }
}
